home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac100% 1998 November
/
MAC100-1998-11.ISO.7z
/
MAC100-1998-11.ISO
/
オンラインソフト定点観測
/
ユーティリティ
/
Mops 3.2.sea
/
Mops 3.2
/
Mops source
/
PPC source
/
qpCreate
< prev
next >
Wrap
Text File
|
1998-05-25
|
6KB
|
279 lines
PPC? not
[IF]
¥ First we have to define a number of VALUEs that are used in the
¥ following files, but before CROSS - we put them here since we're
¥ about to redefine VALUE.
¥ Well actually there's no need to any more, but this works...
0 value theObj ¥ needed by qClass
0 value ^xarea
0 value loc_addr ¥ needed by qArgs
0 value objClass ¥ a new version of this value - otherwise if we
¥ have an error dump in the code generation, the
¥ plot gets badly lost.
[THEN]
(* ============================
The following probably won't be needed when we're running the code
generator on the PPC itself. We redefine a number of words such as
CREATE to use PPC_HEADER rather than revector the existing HEADER, since
running on the PPC the 68k version of HEADER won't exist, of course.
We then redefine VALUE so we can have PPC-style VALUEs from now on.
We couldn't do it earlier since we need 68k-style values to run
this code on the 68k.
============================
*)
: (CREATE) ¥ ( hndlr-code -- )
[ ppc? ] [if] header [else] ppc_header [then]
codeW, 0 codeW, ¥ store handler code and align
CDP 0 code,
DP swap reloc! ¥ store reloc pointer to data area
;
: (sCREATE) ¥ ( addr len hndlr-code -- )
down [ ppc? ] [if] sHdr [else] ppc_sHdr [then]
codeW, 0 codeW, ¥ store handler code and align
CDP 0 code,
DP swap reloc!
;
PPC?
[IF]
: CREATE
$ BC04 (create) ;
: sCreate
$ BC04 (sCreate) ;
: VARIABLE
align4 ¥ align in data area
create 0 , ;
: CONSTANT ¥ these are stored in the code area
header
$ BC02 codeW, 0 codeW, ¥ store handler code and align
code, ; ¥ then the constant itself
: VALUE
align4 ¥ align in data area
$ BC03 (create) , ;
: FCONSTANT
header
$ BC26 codeW,
CDP 7 + $ fffffff8 and -> CDP
CDP f! 8 ++> CDP
;
: FVALUE
align8
$ BC27 (create)
DP f! 8 ++> DP
;
: OBJPTR
align4 ¥ align in data area
$ BC1F (create)
nilP , 0 , ;
[ELSE]
: CREATE
ppc?
IF $ BC04 (create)
ELSE create
THEN
;
: createx create ;
: sCreate
$ BC04 (sCreate) ;
: VARIABLE
ppc?
IF align4 ¥ align in data area
create 0 ,
ELSE variable
THEN
;
: CONSTANT ¥ these are stored in the code area
ppc?
IF ppc_header
$ BC02 codeW, 0 codeW, ¥ store handler code and align
code,
ELSE constant
THEN
;
: VALUE
ppc?
IF align4 ¥ align in data area
$ BC03 (create) ,
ELSE value
THEN
;
: valuex value ;
[THEN]
: OBJPTR
align4 ¥ align in data area
$ BC1F (create)
nilP , 0 , ;
¥ On the PPC, thankfully, <BUILDS can be the same as CREATE!
¥ If we decide we need PPC <builds...does> in 68k mode, put it here:
PPC?
[IF]
: <BUILDS create 0 code, ;
: fix_does { ¥ cfa -- }
latest name> -> cfa
$ BC0C cfa 2- w! ¥ change handler code to does_h
¥ now we have to locate the runtime (does) code - this will
¥ come soon after where we were called from, so we just scan
¥ forward for the $ BE00 handler code for the :noname
¥ definition. As this isn't a leaf proc, our return addr
¥ is on the top of the return stack.
r@
BEGIN
dup w@ $ BE00 =
NWHILE
4+
REPEAT
2+ cfa 6 + reloc! ¥ and put reloc addr of runtime (does)
¥ after the reloc addr of the data code
;
: DOES>
postpone fix_does ¥ the CREATE code will finish with fix_does
" ;" evaluate ¥ finish off the CREATE code
:noname ¥ start a :noname defn for the DOES> code
nip ¥ don't need xt - leave security marker
¥ for final ; to consume
; immediate
[THEN]
: VECT
align4
$ BC05 (create)
DP 4 ++> DP
reloc! ;
: SVECT ¥ system vectors are really only for Mops internal use.
¥ they have a default value 4 bytes after the regular one, which
¥ gets used if the regular value is zero.
align4
$ BC3D (create)
0 , ¥ initial "regular value" is zero
DP 4 ++> DP
reloc!
;
(* Dynamic vectors are "lightweight" vectors in which we don't use a relocatable
addr but just store the xt to be executed, which allows us to point into
a module if we know it's safe. These should never be saved in the dic and used
after reloading - hence the name "dynamic". Like system vectors, zero means
use the default, but the default is always do nothing.
*)
: DYNAMICVECT
align4
$ BC3B (create)
0 , ¥ initial value is zero
;
PPC?
[IF]
¥ in zBase
[ELSE]
: (createObj) ¥ temp, for hand-winding an object while testing.
¥ in data area:
align4 ¥ must be aligned
0 , ¥ reserve space for class pointer
-2 w, ¥ offset to indexed length word (-2 if not
¥ indexed)
-6 w, ¥ offset to start of obj header
¥ (DP is now at start of obj data)
¥ in code area:
$ BC0B (create) ¥ create with obj_h handler code, with
¥ reloc ptr to obj data
;
(* For MARKER, we don't use <builds...does> as on the 68k, since
there's no need to put the marker info in the data area, 'cause
it's only used during development. A marker just becomes a
defn with a special handler code, and we put the associated
info straight after the header in the code area.
We can't execute the marker in the handler, since at that stage
we're probably in the execution buffer so resetting CDP wouldn't
be very sensible. So we just compile a call to (mrk) which does
the work, and leave the new CDP in a value for (mrk) to pick up.
*)
: MARKER
crossed? 0EXIT ¥ just in case - mustn't monkey with CDP
¥ before it's set up!!
CDP
ppc_header
$ BC410000 code, ¥ marker_h handler code, and alignment
¥ Note - we'll indicate a file mark
¥ by putting something nonzero in these
¥ pad bytes
( orig-CDP ) displCode,
DP displCode,
;
0 value cdp2use
: (mrk)
cdp2use
dup displace -> CDP 4+
displace -> DP 4+
CDP (forget) ¥ fixes CONTEXT and LATEST
-echo
;
:f marker_h ( xt -- )
2+ -> cdp2use
['] (mrk) (comp)
;f
[THEN]